import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
#//*[@id="fromStationText"] 出发地
#//*[@id="toStationText"] 到达地
browser = webdriver.Chrome()
browser.get('https://www.12306.cn/index/')
# 定位到12306的出发地
id_from_word = 'fromStationText'
#使用tuple
locator = (By.ID, id_from_word)
#开始解析网页，强制等待10秒，如果没有返回网页就自动抛出异常
wait = WebDriverWait(browser, 10).until(EC.presence_of_element_located(locator))
#
input = browser.find_element(By.ID, id_from_word)

input.clear()
input.send_keys('北京')

id_to_word = 'toStationText'

locator1 = (By.ID, id_to_word)

input1 = browser.find_element(By.ID, id_to_word)

input1.clear()
input1.send_keys('拉萨')
time.sleep(5)
browser.quit()